<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div{
      width: 200px;
      height: 200px;
      background-color: aqua;
    }
  </style>
</head>
<body>
  <canvas id="canvas" width="400" height="400"></canvas>
  <canvas id="canvas2" width="400" height="400"></canvas>
  <div>

  </div>
  <script>
    /** @type {HTMLCanvasElement} */
    var canvas=document.querySelector("#canvas")
    var canvas2=document.querySelector("#canvas2")
    var div=document.querySelector("div")
    var ctx=canvas.getContext("2d")
    var ctx2=canvas2.getContext("2d")
    var img=new Image()
    img.crossOrigin = 'Annoymous'
    img.src="https://c-ssl.duitang.com/uploads/item/201907/22/20190722171500_fshfb.thumb.1000_0.jpg"
    img.onload=function(){
      ctx.drawImage(img,0,0,400,400)
    }
    canvas.onmousemove=function(e){
      // console.log(e.pageX);
      var x=e.pageX
      var y=e.pageY
      if(x<=80||y<=80){
        x=80
        y=80
      }
      var xs=ctx.getImageData(x,y,1,1)
      var rgb="rgba("+xs.data[0]+","+xs.data[1]+","+xs.data[2]+","+xs.data[3]/255+")"
      div.innerHTML=rgb
      ctx2.clearRect(0,0,400,400)
      ctx2.drawImage(img,x*2.5-100,y*2.5-100,200,200,0,0,400,400)
    }
  </script>
</body>
</html>